package com.tarena.dubbo.order.web.service;

import com.tarena.dubbo.order.web.pojo.Order;
import com.tarena.dubbo.stock.api.StockApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class OrderService {
    @DubboReference
    private StockApi stockApi;

    public void createOrder(Order order) {
        //TODO 调用减库存
        boolean b = stockApi.reduceStock(order.getProductId(), order.getCount());
        if (b){
            log.info("创建订单数据:{},创建订单成功",order);
        }


    }
}
